<?php
/**
 * Necros View for Congregation Component
 * 
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_4
 * @license		GNU/GPL
 */

// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view' );

/**
 * Necros View
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class CongregationViewNecros extends CongregationView
{
	/**
	 * Sharings view display method
	 * @return void
	 **/

	 
	function display($tpl = null)
	{
	
		JToolBarHelper::deleteList();
		JToolBarHelper::editListX();
		JToolBarHelper::addNewX();
		JToolBarHelper::back(JText::_('Back'), JRoute::_( 'index.php?option=com_congregation'));

		JHTML::_('behavior.tooltip');
		
		$context			= 'com_congregation.necros.default';
		$order_by		= $this->_mainframe->getUserStateFromRequest( $context.'order_by',		'order_by',		'lname',	'string' );
		$order_dir	= $this->_mainframe->getUserStateFromRequest( $context.'order_dir',	'order_dir',	'',			'string' );
		$search				= $this->_mainframe->getUserStateFromRequest( $context.'search',			'search',			'',			'string' );
		$year = $this->_mainframe->getUserStateFromRequest( $context.'year',			'year',			'',			'string' );
		if (strpos($search, '"') !== false) {
			$search = str_replace(array('=', '<'), '', $search);
		}
		$search = JString::strtolower($search);

		$limit		= $this->_mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $this->_mainframe->getCfg('list_limit'), 'int' );
		$limitstart = $this->_mainframe->getUserStateFromRequest( $context.'limitstart', 'limitstart', 0, 'int' );



		JRequest::setVar('limit',       (int) $limit);
		JRequest::setVar('limitstart',  (int) $limitstart);
		JRequest::setVar('search',      $search);
		JRequest::setVar('year',      $year);
		JRequest::setVar('order_by',        $order_by);
		JRequest::setVar('order_dir',        $order_dir);

		$lists = array();

		// table ordering
		$lists['order_by']	= $order_by;
		$lists['order_dir']		= $order_dir;

		// search filter
		$lists['search']= $search;    
		
		$lists['years'] = & $this->get('Years');
		$lists['year'] = $year;
		$total = 0;
		if($items		= & $this->get( 'Data'))
		{
			$total		= & $this->get( 'Total' );
		}
		
		
		JToolBarHelper::title(   JText::_( 'Necro manager' ), 'generic.png' );
		
		jimport('joomla.html.pagination');
		$pagination = new JPagination($total, $limitstart, $limit);
		$this->assignRef('items',		$items);
		$this->assignRef('pagination',  $pagination);
		$this->assignRef('lists',       $lists);

		parent::display($tpl);
	}
	

}
